package com.itheima.appserver.service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.appserver.interceptor.UserThreadLocal;
import com.itheima.commons.pojo.domain.HuanxinUser;
import com.itheima.dubbo.interfaces.HuanxinUserApi;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yaohu
 * @date 2021/12/11
 * @Version 1.0
 * @describe
 */
@Service
public class HuanxinService {

    @Reference
    private HuanxinUserApi huanxinUserApi;

    /**
     * 根据token中的userId查询环信用户信息
     *
     * @return
     */
    public Map<String, String> queryHuanXinUser() {
        HuanxinUser huanxinUser = huanxinUserApi.findHXUserByUserId(UserThreadLocal.getUserId());
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("username", huanxinUser.getUsername());
        hashMap.put("password", huanxinUser.getPassword());
        return hashMap;
    }
}
